package com.cz.udi;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DelTuoCode {
    public static void main(String[] args) {
        try {
            Map<String,Object> params = new HashMap<>();
            params.put("material_id",1);
            params.put("warehouse_id",78);

            String group = "udi";
            String sql = "select tuo_id from fl_tuocode where warehouse_id=:warehouse_id and material_id = :material_id";
            List<Entity> list = Db.use(group).query(sql,params);
            System.out.println("托码个数:"+list.size());
            for (Entity entity : list) {
                int tuoId = entity.getInt("tuo_id");
                int result = Db.use(group).execute("delete from fl_tuocode where tuo_id = ?", tuoId);
                System.out.println("删除条码结果:"+result);
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
